<?php
namespace app\common\logic;

use app\common\model\CarBrands;
use think\Env;


class CarBrandsLogic extends BaseLogic
{
    public $model;

    public function assignModel()
    {
        $this->model          = new CarBrands();
    }

    /**
     * 获取所有品牌
     * @return array
     * @throws \think\exception\DbException
     */
    public function index()
    {
        $brands       = $this->getList()->toArray();
        //把获取到首字母的数组排序
        $sort="SORT_ASC";
        $brands= arraySequence($brands, "letter",$sort);
        //创建新数组
        $data = [];
        //通过字段相同的分到一个新数组
        foreach($brands as &$v){
            $v['logo'] = Env::get('app.app_host').$v['logo'];
            $data[$v['letter']][]=$v;
        }
        return $data;
    }


}